extends Node2D

@onready var tile_map: TileMap = $TileMap
@onready var camera_2d: Camera2D = $Player/Camera2D

func _ready() -> void:
	var used_rect := tile_map.get_used_rect().grow(-1)
	var tile_size := tile_map.tile_set.tile_size
	
	var limit_top := used_rect.position.y * tile_size.y
	var limit_right := used_rect.end.x * tile_size.x
	var limit_bottom := used_rect.end.y * tile_size.y
	var limit_left := used_rect.position.x * tile_size.x
	
	camera_2d.limit_top = limit_top
	camera_2d.limit_right = limit_right
	camera_2d.limit_bottom = limit_bottom
	camera_2d.limit_left = limit_left
	
	camera_2d.reset_smoothing()
